package com.osdp.base.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.osdp.common.entity.BaseEntity;
import lombok.*;
import lombok.experimental.Accessors;


/**
 *  树型结构字典表
 *
 * @Author
 * @since
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
//@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("sys_dict_item")
public class SysDictItem extends BaseEntity {

    private static final long serialVersionUID = 1L;

    public static final String ROOT_PARENT_ID = "0";

    /**
     * 编码code
     */
    private String dictItemCode;
    /**
     * 父ID
     * FieldStrategy.IGNORED字段允许为null
     */
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String parentId;

    /**
     * 字典项文本
     */
    private String itemText;

    /**
     * 字典项值
     */
    private String itemValue;

    /**
     * 描述
     */
    private String description;

    /**
     * 排序
     */
    private Integer sortNo;

    /**
     * 判断ID是否根节点
     * @param id
     * @return
     */
    public static boolean root(String id){
        return "0".equals(id);
    }


    public SysDictItem(){}

    public SysDictItem(String dictItemCode,String itemText, String itemValue) {
        this.dictItemCode = dictItemCode;
        this.itemText = itemText;
        this.itemValue = itemValue;
    }
}
